import axios from '@/libs/api.request'
// import StringUtil from '@/libs/string-util'

const api_module = 'monitor/job'

const all = () => {
  return axios.request({
    url: `api/${api_module}/list`,
    method: 'get'
  })
}

const toggleTaskStatus = (jobId) => {
  return axios.request({
    url: `api/${api_module}/${jobId}/changeStatus`,
    method: 'post'
  })
}

const runTask = (jobId) => {
  return axios.request({
    url: `api/${api_module}/run/${jobId}`,
    method: 'post'
  })
}

const add = (job) => {
  return axios.request({
    url: `api/${api_module}/add`,
    method: 'post',
    data: job
  })
}

const edit = (job) => {
  return axios.request({
    url: `api/${api_module}/edit`,
    method: 'post',
    data: job
  })
}

const remove = (jobId) => {
  return axios.request({
    url: `api/${api_module}/remove`,
    method: 'post',
    params: {
      ids: jobId
    }
  })
}

export default {
  all,
  toggleTaskStatus,
  runTask,
  add,
  edit,
  remove
}
